package com.kingyun.gpsinspection.purificationservice.services.tdm.outerservice.impl;

import com.alibaba.fastjson.JSONObject;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.tdm.CheckRepairMapper;
import com.kingyun.gpsinspection.purificationservice.facade.model.tdm.CRWebServiceVo;
import com.kingyun.gpsinspection.purificationservice.facade.service.tdm.CheckRepairWebService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 检查维修对外接口
 * Created by jiangjx on 2017/2/16.
 */
public class CheckRepairWebServiceImpl implements CheckRepairWebService {

    @Autowired
    private CheckRepairMapper checkRepairMapper;

    /**
     * 查询检查维修任务
     * （模糊搜索只搜索任务名称与任务内容。）
     * （高级搜索为crWebServiceVo类全属性，但只取非空值属性。）
     * （查询条件中的日期的属性，只取到年月日，不取时分秒。）
     *
     * @param crWebServiceVo 查询条件封装类
     * @return JSONObject
     */
    @Override
    public JSONObject queryCheckRepair(CRWebServiceVo crWebServiceVo) {
        JSONObject jsonObject = new JSONObject();
        crWebServiceVo.setLimit(crWebServiceVo.getLimit() == null ? 10 : crWebServiceVo.getLimit());
        crWebServiceVo.setOffset(crWebServiceVo.getOffset() == null ? 0 : crWebServiceVo.getOffset());
        jsonObject.put("total", checkRepairMapper.queryCount(crWebServiceVo));
        List<CRWebServiceVo> list = checkRepairMapper.queryList(crWebServiceVo);
        jsonObject.put("rows", list);
        return jsonObject;
    }
}
